// STL integration

#include <iondrive/std.h>
#include <iondrive/glsl.h>

using namespace iondrive;


int main()
{

	// glsl::vec<std::complex<float>,10> x;

	iondrive::glsl::vec<int,19> x;

	std::vector<int> v,u;

	std::copy(x.begin(),x.end(),u.begin());
	
	return 0;
}


int tmp_bla = 0;
void foo2();



void foo()
{
	using namespace std;
	
//XXX	try
	{
		iondrive::glsl::vec<int,10> myIntList;
		iondrive::glsl::vec<int,10>::iterator Iter;
		// Add some ints to the list


		for( int i = 0; i < 5; i++ ) {
//XXX			myIntList.push_back( i + 1 );
		}

		cout << "List contains (" << myIntList.size() << ") elements" << endl;
		cout << "Printing list contents..." << endl;
		// Print to the screen using 1 method
		std::copy( myIntList.begin(),
			   myIntList.end(),
			   ostream_iterator<int>( cout, "\n" ) );

		cout << "Printing again..." << endl;
		// Print using another method
		for(  Iter = myIntList.begin();
		      Iter != myIntList.end();
		      Iter++ )
		{
			cout << *Iter << endl;
		}

		cout << "Sorting with std::sort()" << endl;
		std::sort( myIntList.begin(), myIntList.end() );

		cout << "Printing again..." << endl;
		std::copy( myIntList.begin(),
			   myIntList.end(),
			   ostream_iterator<int>( cout, "\n" ) );

		cout << "Sorting with internal list qsort()" << endl;
		// Set the comparison function
//XXX		myIntList.setcompare( ReverseIntCompare );

//XXX		myIntList.sort();

		// Print the sorted list (now in reverse order)
		cout << "Printing again..." << endl;
		std::copy( myIntList.begin(),
			   myIntList.end(),
			   ostream_iterator<int>( cout, "\n" ) );
	}
//XXX	catch( CIDListException &e ) {
//XXX		cout << "CIDLinkedList exception caught!" << endl;
//XXX		cout << "Reason: " << e.Why() << endl;
//XXX	}

	if (tmp_bla == 4) { foo2(); }
}

void foo2()
{
	std::array<float,3> myarray;
	glsl::vec<float,3> somevec(1);

	somevec.sin(somevec+cos(somevec));
	
	std::copy(somevec.begin(),somevec.end(),myarray.begin());

	tmp_bla = (int) (myarray.front() + myarray.back());
}





//eof
